﻿using System.Data.Entity;

namespace KPIS.GERP.Models
{
    public class GERPContext : DbContext
    {
        #region ACM

        public DbSet<ACM.ChangeValue> ChangeValues { get; set; }
        public DbSet<ACM.MasAccount> MasAccount { get; set; }
        public DbSet<ACM.MasAccountVersion> MasAccountVersions { get; set; }
        //public DbSet<ACM.MasAccounts> MasAccounts { get; set; }
        public DbSet<ACM.MasBaseAccount> MasBaseAccounts { get; set; }
        public DbSet<ACM.MasFiscalPeriod> MasFiscalPeriods { get; set; }
        public DbSet<ACM.Transection> Transections { get; set; }
        public DbSet<ACM.TransectionDtl> TransectionDtls { get; set; }
        public DbSet<ACM.TransectionGroup> TransectionGroups { get; set; }

        #endregion

        #region BGM

        public DbSet<BGM.MasBudgetSource> MasBudgetSources { get; set; }
        public DbSet<BGM.MasBudgetSourceType> MasBudgetSourceTypes { get; set; }
        public DbSet<BGM.MasBudgetExpense> MasBudgetExpenses { get; set; }
        public DbSet<BGM.MasBudgetExpenseGroup> MasBudgetExpenseGroups { get; set; }
        public DbSet<BGM.MasBudgetExpenseSource> MasBudgetExpenseSources { get; set; }
        public DbSet<BGM.Project> Projects { get; set; }
        public DbSet<BGM.ProjectExpense> ProjectExpenses { get; set; }
        public DbSet<BGM.ProjectActivityPlan> ProjectActivityPlans { get; set; }
        public DbSet<BGM.ProjectManager> ProjectManagers { get; set; }
        public DbSet<BGM.ProjectOption> ProjectOptions { get; set; }
        public DbSet<BGM.ProjectReport> ProjectReports { get; set; }
        public DbSet<BGM.ProjectOperation> ProjectOperations { get; set; }
        public DbSet<BGM.ProjectOperationExpense> ProjectOperationExpenses { get; set; }
        public DbSet<BGM.ProjectOperationPerson> ProjectOperationPersons { get; set; }
        public DbSet<BGM.ProjectOperationReport> ProjectOperationReports { get; set; }
        public DbSet<BGM.MasScopes> ProjectScopeses { get; set; }
        public DbSet<BGM.ProjectType> ProjectTypes { get; set; }
        public DbSet<BGM.StrategyDataList> StrategyDataLists { get; set; }
        public DbSet<BGM.SystemControl> SystemControls { get; set; }

        #endregion

        #region FIM

        public DbSet<FIM.Cheque> Cheques { get; set; }
        public DbSet<FIM.MasBank> MasBanks { get; set; }
        public DbSet<FIM.MasBankBranch> MasBankBranchs { get; set; }
        public DbSet<FIM.MasBankAccount> MasBankAccounts { get; set; }
        public DbSet<FIM.MasExpenseRate> MasExpenseRates { get; set; }
        public DbSet<FIM.MasBankAccountType> MasBankAccountTypes { get; set; }
        public DbSet<FIM.MasBankAccountTypeGroup> MasBankAccountTypeGroups { get; set; }
        public DbSet<FIM.MasReceiveType> MasReceiveTypes { get; set; }
        public DbSet<FIM.MasBorrowType> MasBorrowTypes { get; set; }
        public DbSet<FIM.ChequeBook> ChequeBooks { get; set; }
        public DbSet<FIM.Transfer> Transfers { get; set; }
        public DbSet<FIM.FimMasLookUp> FimMasLookUps { get; set; }
        public DbSet<FIM.FimMasLookUpType> FimMasLookUpTypes { get; set; }
        public DbSet<FIM.Petition> Petitions { get; set; }
        public DbSet<FIM.PayRequest> PayRequests { get; set; }
        public DbSet<FIM.PayRequestDtl> PayRequestDtls { get; set; }
        public DbSet<FIM.PayRequestDtlRate> PayRequestDtlRates { get; set; }
        public DbSet<FIM.Pay> Pays { get; set; }
        public DbSet<FIM.PayCheque> PayCheques { get; set; }
        public DbSet<FIM.Receive> Receives { get; set; }
        public DbSet<FIM.Return> Returns { get; set; }
        public DbSet<FIM.EmployeeTax> EmployeeTaxs { get; set; }

        #endregion

        #region ICM

        public DbSet<ICM.MasPurchaseMethod> MasPurchaseMethods { get; set; }
        public DbSet<ICM.MasPurchaseRegular> MasPurchaseRegulars { get; set; }
        public DbSet<ICM.MasPurchaseRegularMapping> MasPurchaseRegularMappings { get; set; }
        public DbSet<ICM.MasUnit> MasUnits { get; set; }
        public DbSet<ICM.MasResourceType> MasResourceTypes { get; set; }
        public DbSet<ICM.MasResourceGroup> MasResourceGroups { get; set; }
        public DbSet<ICM.MasResourceSubGroup> MasResourceSubGroups { get; set; }
        public DbSet<ICM.MasResourceItem> MasResourceItems { get; set; }
        public DbSet<ICM.MasContact> MasContacts { get; set; }
        public DbSet<ICM.MasContactBank> MasContactBanks { get; set; }
        public DbSet<ICM.MasContactPartner> MasContactPartners { get; set; }
        public DbSet<ICM.Received> Receiveds { get; set; }
        public DbSet<ICM.Warehouse> Warehouses { get; set; }
        public DbSet<ICM.WarehousePermit> WarehousePermits { get; set; }
        public DbSet<ICM.IcmMasLookUpType> IcmMasLookUpTypes { get; set; }
        public DbSet<ICM.IcmMasLookUp> IcmMasLookUps { get; set; }
        public DbSet<ICM.DeliveryNote> DeliveryNotes { get; set; }
        public DbSet<ICM.ReceiveDtl> ReceiveDtls { get; set; }
        public DbSet<ICM.Asset> Assets { get; set; }
        public DbSet<ICM.AssetDepreciation> AssetDepreciations { get; set; }
        public DbSet<ICM.AssetWarranty> AssetWarrantys { get; set; }
        public DbSet<ICM.OfficeSuppliesLot> OfficeSuppliesLots { get; set; }
        public DbSet<ICM.RequestParcel> RequestParcels { get; set; }
        public DbSet<ICM.RequestParcelDtl> RequestParcelDtls { get; set; }
        public DbSet<ICM.Dispense> Dispenses { get; set; }
        public DbSet<ICM.DispenseHistory> DispenseHistorys { get; set; }
        public DbSet<ICM.Movement> Movements { get; set; }
        public DbSet<ICM.MovementDtl> MovementDtls { get; set; }
        public DbSet<ICM.PurchaseRequest> PurchaseRequests { get; set; }
        public DbSet<ICM.PurchaseRequestItem> PurchaseRequestItems { get; set; }
        public DbSet<ICM.PrePurchaseRequest> PrePurchaseRequests { get; set; }
        public DbSet<ICM.MasPurchaseType> MasPurchaseTypes { get; set; }
        public DbSet<ICM.PrePurchaseRequestItem> PrePurchaseRequestItems { get; set; }
        public DbSet<ICM.Committee> Committees { get; set; }
        public DbSet<ICM.CommitteeGroup> CommitteeGroups { get; set; }
        public DbSet<ICM.File> Files { get; set; }
        public DbSet<ICM.Bid> Bids { get; set; }
        public DbSet<ICM.Bidder> Bidders { get; set; }
        public DbSet<ICM.BidderCollateral> BidderCollaterals { get; set; }
        public DbSet<ICM.BidderQuotation> BidderQuotations { get; set; }
        public DbSet<ICM.MovementHistory> MovementHistorys { get; set; }
        public DbSet<ICM.DeliveryNoteItem> DeliveryNoteItems { get; set; }
        public DbSet<ICM.PurchaseOrderInstallmentItem> PurchaseOrderInstallmentItems { get; set; }
        public DbSet<ICM.DeliveryNoteItemExtra> DeliveryNoteItemExtras { get; set; }
        public DbSet<ICM.MasDepreciationType> MasDepreciationTypes { get; set; }
        public DbSet<ICM.PurchaseOrderInstallment> PurchaseOrderInstallments { get; set; }
        public DbSet<ICM.PurchaseOrder> PurchaseOrders { get; set; }
        public DbSet<ICM.PurchaseOrderItem> PurchaseOrderItems { get; set; }
        public DbSet<ICM.PurchaseOrderPenalty> PurchaseorderPenalties { get; set; }
        public DbSet<ICM.DeliveryNotePenalty> DeliveryNotePenalties { get; set; }
        public DbSet<ICM.InventoryRepair> InventoryRepairs { get; set; }
        public DbSet<ICM.MasDealerRepair> MasDealerRepairs { get; set; }
        public DbSet<ICM.InventoryStockTaking> InventoryStockTakings { get; set; }
        public DbSet<ICM.InventoryStockTakingItem> InventoryStockTakingItems { get; set; }
        public DbSet<ICM.Dispose> Disposes { get; set; }
        public DbSet<ICM.DisposeOfficeSupplylotHistory> DisposeOfficeSupplylotHistorys { get; set; }

        #endregion

        #region SYS

        public DbSet<SYS.UserLoginMonitor> UserLoginMonitors { get; set; }
        public DbSet<SYS.UserLoginLogout> UserLoginLogouts { get; set; }
        public DbSet<SYS.OTP> Otps { get; set; }
        // public DbSet<SYS.OTPData> OtpDatas { get; set; }
        public DbSet<SYS.User> Users { get; set; }
        public DbSet<SYS.YearType> YearTypes { get; set; }
        public DbSet<SYS.MessageWarning> MessageWarnings { get; set; }
        //public DbSet<SYS.Message> Messages { get; set; }
        public DbSet<SYS.MessageSend> MessageSends { get; set; }
        public DbSet<SYS.MessageReply> MessageReplys { get; set; }
        // public DbSet<SYS.MenuItemList> MenuItemLists { get; set; } //Unused
        public DbSet<SYS.MenuItemsList> MenuItemsLists { get; set; }
        public DbSet<SYS.Role> Roles { get; set; }
        public DbSet<SYS.UserRole> UserRoles { get; set; }
        public DbSet<SYS.Permission> Permissions { get; set; }
        public DbSet<SYS.SysSystemControl> SysSystemControls { get; set; }
        public DbSet<SYS.RouteStatus> RouteStatuses { get; set; }
        public DbSet<SYS.ApprovePath> ApprovePaths { get; set; }
        public DbSet<SYS.ExecPosGroup> ExecPosGroups { get; set; }
        public DbSet<SYS.ExecPosGroupDtls> ExecPosGroupDtlses { get; set; }
        public DbSet<SYS.ApproveProcess> ApproveProcesses { get; set; }
        public DbSet<SYS.ApproveProcessGroup> ApproveProcessGroups { get; set; }
        //public DbSet<SYS.ApprovalTask> ApprovalTasks { get; set; }
        //public DbSet<SYS.ApprovalTaskDtl> ApprovalTaskDtls { get; set; }
        //public DbSet<SYS.ApprovalTaskDtlEmployee> ApprovalTaskDtlEmployees { get; set; }
        public DbSet<SYS.SearchResult> SearchResults { get; set; }
        public DbSet<SYS.SearchResultDtl> SearchResultDtls { get; set; }
        public DbSet<SYS.Task> Tasks { get; set; }
        public DbSet<SYS.TaskHistory> TaskHistories { get; set; }
        //public DbSet<SYS.TaskHistoryNotification> TaskHistoryNotifications { get; set; }
        //public DbSet<SYS.TaskHistoryMessage> TaskHistoryMessages { get; set; }
        public DbSet<SYS.ApprovePathSimulate> ApprovePathSimulates { get; set; }
        public DbSet<SYS.ServerStartUp> ServerStartUps { get; set; }
        public DbSet<SYS.ApproveProcessMapping> ApproveProcessMappings { get; set; }
        public DbSet<SYS.SchedulerReport> SchedulerReports { get; set; }
        public DbSet<SYS.SchedulerReportCmdDtl> SchedulerReportCmds { get; set; }
        
        
        #endregion

        #region HRM

        public DbSet<HRM.MasGender> MasGenders { get; set; }
        public DbSet<HRM.MasNamePrefix> MasNamePrefixs { get; set; }
        public DbSet<HRM.MasEmployeeType> MasEmployeeTypes { get; set; }
        public DbSet<HRM.Employee> Employees { get; set; }
        public DbSet<HRM.MasJobSiteType> MasJobSiteTypes { get; set; }
        public DbSet<HRM.MasJobSiteLevel> MasJobSiteLevels { get; set; }
        public DbSet<HRM.MasJobSiteStatus> MasJobSiteStatuses { get; set; }
        public DbSet<HRM.Position> Positions { get; set; }
        public DbSet<HRM.DcPenalty> Penalties { get; set; }
        public DbSet<HRM.MasPositionType> MasPositionTypes { get; set; }
        public DbSet<HRM.FieldPosition> FieldPositions { get; set; }
        public DbSet<HRM.MasPositionStatus> MasPositionStatuses { get; set; }
        public DbSet<HRM.JobSite> JobSites { get; set; }
        public DbSet<HRM.MasScope> MasScopes { get; set; }
        public DbSet<HRM.ExecutivePosition> ExecutivePositions { get; set; }
        public DbSet<HRM.MasWorkArea> MasWorkAreas { get; set; }
        public DbSet<HRM.PsCommand> PsCommands { get; set; }
        public DbSet<HRM.PsCommandDtls> PsCommandDtls { get; set; }
        public DbSet<HRM.PsCommandType> PsCommandTypes { get; set; }
        public DbSet<HRM.PsEmpContact> PsEmpContacts { get; set; }
        public DbSet<HRM.MpScope> MpScopes { get; set; }
        public DbSet<HRM.MpDuty> MpDuties { get; set; }
        public DbSet<HRM.EsQuitRequest> EsQuitRequests { get; set; }
        public DbSet<HRM.PsEmployeeStatus> PsEmployeeStatus { get; set; }
        //public DbSet<HRM.PsEmployeeType> PsEmployeeTypes { get; set; }
        public DbSet<HRM.MpPosition> MpPositions { get; set; }
        public DbSet<HRM.MpPositionWorkOnDuty> MpPositionWorkOnDuties { get; set; }
        // remove: use ExecutivePosition class instead (tablename = "hrm_mp_exec_positions") public DbSet<HRM.MpExecPosition> MpExecPositions { get; set; }
        public DbSet<HRM.MpFieldPosition> MpFieldPositions { get; set; }
        public DbSet<HRM.MpFieldDuty> MpFieldDuties { get; set; }
        public DbSet<HRM.MpFieldDutyDtls> MpFieldDutyDtls { get; set; }
        public DbSet<HRM.MpFieldGroup> MpFieldGroups { get; set; }
        public DbSet<HRM.MpFieldSpecificationDtls> MpFieldSpecificationDtls { get; set; }
        public DbSet<HRM.MpFieldSpecification> MpFieldSpecifications { get; set; }
        public DbSet<HRM.PsEmpEducation> PsEmpEducations { get; set; }
        public DbSet<HRM.MasEduQualification> MasEduQualifications { get; set; }
        public DbSet<HRM.MasEduDegree> MasEduDegrees { get; set; }
        public DbSet<HRM.MasEduMajor> MasEduMajors { get; set; }
        public DbSet<HRM.MasEduInstitute> MasEduInstitutes { get; set; }
        public DbSet<HRM.PsEmpEnglish> PsEmpEnglishs { get; set; }
        public DbSet<HRM.PsEmpGoodness> PsEmpGoodness { get; set; }
        public DbSet<HRM.PsEduHistory> PsEduHistories { get; set; }
        public DbSet<HRM.PsEmpIncrease> PsEmpIncreases { get; set; }
        public DbSet<HRM.EmpPositionHistory> PsEmpPositionHistories { get; set; }
        public DbSet<HRM.PsEmpNameHistory> PsEmpNameHistories { get; set; }
        public DbSet<HRM.PsEmpSalaryHistory> PsEmpSalaryHistories { get; set; }
        public DbSet<HRM.PsEmpMovment> PsEmpMovments { get; set; }
        public DbSet<HRM.PsEmpSpouse> PsEmpSpouses { get; set; }
        public DbSet<HRM.PsEmpChildren> PsEmpChildrens { get; set; }
        public DbSet<HRM.PsEmpParent> PsEmpParents { get; set; }
        public DbSet<HRM.RcInquireSubject> RcInquireSubjects { get; set; }
        public DbSet<HRM.MpJobSiteArea> MpJobSiteAreas { get; set; }
        public DbSet<HRM.MpJobSiteCommand> MpJobSiteCommands { get; set; }
        public DbSet<HRM.MpJobSiteCommandDtls> MpJobSiteCommandDtls { get; set; }
        public DbSet<HRM.MpJobSiteType> MpJobSiteTypes { get; set; }
        public DbSet<HRM.MpJobSpecification> MpJobSpecifications { get; set; }
        public DbSet<HRM.PsEmpLegatee> PsEmpLegatees { get; set; }
        public DbSet<HRM.MasAmphur> MasAmphurs { get; set; }
        public DbSet<HRM.MpArea> MpAreas { get; set; }
        public DbSet<HRM.MasBloodGroup> MasBloodGroups { get; set; }
        public DbSet<HRM.MasCountry> MasCountries { get; set; }
        public DbSet<HRM.MasCity> MasCities { get; set; }
        public DbSet<HRM.MasCountryZone> MasCountryZones { get; set; }
        public DbSet<HRM.MasDistrict> MasDistricts { get; set; }
        public DbSet<HRM.MasFamilyhood> MasFamilyhoods { get; set; }
        public DbSet<HRM.MasMaritalStatus> MasMaritalStatus { get; set; }
        public DbSet<HRM.MasNationality> MasNationalities { get; set; }
        public DbSet<HRM.MasProvince> MasProvinces { get; set; }
        public DbSet<HRM.MasRecordStatus> MasRecordStatus { get; set; }
        public DbSet<HRM.MasRegion> MasRegions { get; set; }
        public DbSet<HRM.MasReligion> MasReligion { get; set; }
        public DbSet<HRM.MasSpecialSkillType> MasSpecialSkillTypes { get; set; }
        public DbSet<HRM.PsNonWorkingDay> PsNonWorkingDays { get; set; }
        public DbSet<HRM.PsNwdJobSite> PsNwdJobSites { get; set; }
        public DbSet<HRM.MpPositionDuty> MpPositionDuties { get; set; }
        public DbSet<HRM.MpPositionDutyDtls> PositionDutyDtls { get; set; }
        public DbSet<HRM.MpClass> MpClass { get; set; }
        public DbSet<HRM.MasClassSpecification> MasClassSpecifications { get; set; }
        public DbSet<HRM.PrExtraType> PrExtraTypes { get; set; }
        public DbSet<HRM.MpPositionStatus> MpPositionStatus { get; set; }
        public DbSet<HRM.TmpEmployee> TmpEmployees { get; set; }
        public DbSet<HRM.RcCatalog> RcCatalogs { get; set; }
        public DbSet<HRM.RcCatalogStatus> RcCatalogStatus { get; set; }
        public DbSet<HRM.PsRetirement> PsRetirements { get; set; }
        public DbSet<HRM.PsRetirementDtls> PsRetirementDtls { get; set; }
        public DbSet<HRM.PsRoyalItemControl> PsRoyalItemControls { get; set; }
        public DbSet<HRM.PsRoyalItem> PsRoyalItems { get; set; }
        public DbSet<HRM.PsRoyalItemHistory> PsRoyalItemHistories { get; set; }
        public DbSet<HRM.PsRoyalItemRepay> PsRoyalItemRepaies { get; set; }
        public DbSet<HRM.PsRoyalItemRepayDtls> PsRoyalItemRepayDtls { get; set; }
        public DbSet<HRM.PsRoyalItemRequest> PsRoyalItemRequests { get; set; }
        public DbSet<HRM.PsRoyalItemType> PsRoyalItemTypes { get; set; }
        public DbSet<HRM.PrSalaryGroup> PrSalaryGroups { get; set; }
        public DbSet<HRM.ScUser> ScUsers { get; set; }
        public DbSet<HRM.PsEmpSpecialExpert> PsEmpSpecialExperts { get; set; }
        public DbSet<HRM.PsEmpSpecialSkill> PsEmpSpecialSkills { get; set; }
        public DbSet<HRM.PsTimeAttendants> PsTimeAttendants { get; set; }
        public DbSet<HRM.PsTimeAttendanceMonthly> PsTimeAttendanceMonthlies { get; set; }
        public DbSet<HRM.TrainingRequest> TrainingRequests { get; set; }
        public DbSet<HRM.TrainingTypeCategory> TrainingTypeCategories { get; set; }
        public DbSet<HRM.TrainingCourse> TrainingCourses { get; set; }
        public DbSet<HRM.TrainingCourseTrainee> TrainingCourseTrainees { get; set; }
        public DbSet<HRM.TrainingCourseQuota> TrainingCourseQuotas { get; set; }
        public DbSet<HRM.TrainingCourseTrainer> TrainingCourseTrainers { get; set; }
        public DbSet<HRM.Trainer> Trainers { get; set; }
        public DbSet<HRM.TrainingInstitute> TrainingInstitutes { get; set; }
        public DbSet<HRM.Scholarship> Scholarships { get; set; }
        public DbSet<HRM.ScholarshipFund> ScholarshipFunds { get; set; }
        public DbSet<HRM.ScholarshipType> ScholarshipTypes { get; set; }
        public DbSet<HRM.ScholarshipGroup> ScholarshipGroups { get; set; }
        public DbSet<HRM.ScholarshipGroupDtls> ScholarshipGroupDtls { get; set; }
        public DbSet<HRM.ScholarshipRequest> ScholarshipRequests { get; set; }
        public DbSet<HRM.PsAbsence> PsAbsences { get; set; }
        //public DbSet<HRM.PsAbsenceRule> PsAbsenceRules { get; set; }
        public DbSet<HRM.RuleAbsence> RuleAbsences { get; set; }
        public DbSet<HRM.PsAbsenceType> PsAbsenceTypes { get; set; }
        public DbSet<HRM.PsAbsenceTypeGroup> PsAbsenceTypeGroups { get; set; }
        public DbSet<HRM.PsAbsenceVacation> PsAbsenceVacations { get; set; }
        public DbSet<HRM.Activity> Activities { get; set; }
        public DbSet<HRM.ActivityRequest> ActivityRequests { get; set; }
        public DbSet<HRM.ActivityType> ActivityTypes { get; set; }
        public DbSet<HRM.SalaryPromote> SalaryPromotes { get; set; }
        public DbSet<HRM.SalaryPromoteDetail> SalaryPromoteDetails { get; set; }
        public DbSet<HRM.HrmSystemControls> HrmSystemControls { get; set; }
        public DbSet<HRM.PsTimeAttSummary> PsTimeAttendanceSummaries { get; set; }
        public DbSet<HRM.PsTimeAttCalAudit> PsTimeAttCalAudits { get; set; }

        #endregion

        #region Initial
        
        private void Config(bool bTracing = false, string strConnString = null)
        {
            Database.SetInitializer<GERPContext>(null);
            if(!bTracing)
            {
                Configuration.AutoDetectChangesEnabled = false;
                Configuration.ValidateOnSaveEnabled = false;
                Configuration.ProxyCreationEnabled = false;
                Configuration.LazyLoadingEnabled = false;
            }
            if (!string.IsNullOrWhiteSpace(strConnString))
            {
                Database.Connection.ConnectionString = strConnString;
            } 
        }

        public GERPContext()
        {
            Config();
        }

        public GERPContext(bool bTracing = false)
        {
            Config(bTracing);
        }

        public GERPContext(bool bTracing = false, string connectionString = null)
        {
            Config(bTracing, connectionString);
        }

        #endregion
    }
}